import js from "@eslint/js"
import globals from "globals"
import tseslint from "typescript-eslint"
import pluginVue from "eslint-plugin-vue"
import { defineConfig } from "eslint/config"
import prettierRecommended from "eslint-plugin-prettier/recommended"
// import autoImport from "./.eslintrc-auto-import.json"
import { createRequire } from "module"

const require = createRequire(import.meta.url)
const autoImport = require("./.eslintrc-auto-import.json")

export default defineConfig([
  {
    files: ["**/*.{js,mjs,cjs,ts,mts,cts,vue}"],
    plugins: { js },
    extends: ["js/recommended"],
    languageOptions: {
      globals: {
        ...globals.browser,
        ...globals.node,
        ...autoImport.globals
      }
    }
  },
  tseslint.configs.recommended,
  pluginVue.configs["flat/essential"],
  {
    files: ["**/*.vue"],
    languageOptions: {
      parserOptions: {
        parser: tseslint.parser
      }
    }
  },
  {
    rules: {
      "no-console": "warn", // 将使用 console 的规则设置为警告
      "vue/multi-word-component-names": "off"
    }
  },
  {
    ignores: [".css", "*.d.ts"]
  },
  prettierRecommended // 覆盖掉eslint 配置的规则
])
